<section class="panel">
	<link rel="stylesheet" href="<?php echo base_url();?>js/datatables/datatables.css" type="text/css" />
	<script src="<?php echo base_url();?>js/jquery.min.js"></script>
	<script src="<?php echo base_url();?>js/datatables/jquery.dataTables.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			oTable = $('#tabel').dataTable();
			$('#cari').on( 'keyup click', function (){
				oTable.fnFilter( $(this).val());
			});
		});
	</script>
	
	<div class="row text-sm wrapper">
		<div class="col-sm-3">
			<div class="input-group">
				<input type="text" class="input-sm form-control" id ="cari" placeholder="Search">
				<span class="input-group-btn">
					<button class="btn btn-sm btn-info" type="button">Go!</button>
				</span>
			</div>
		</div>
	</div>
	<div class="table-responsive">
		<table id = "tabel" class="table table-striped b-t text-sm">
			<thead>
				<tr>
					<th class="th-sortable" data-toggle="class">No
						<span class="th-sort">
							<i class="fa fa-sort-down text"></i>
							<i class="fa fa-sort-up text-active"></i>
							<i class="fa fa-sort"></i>
						</span>
					</th>
					<th>Lihat</th>
					<th>Tanggal pengajuan</th>
					<th>Nama lengkap</th>
					<th>Sekolah</th>
					<th>Status</th>
				</tr>
			</thead>
			<tbody>
				<?php
					$no = 0;
					foreach($users as $user)
					{
						$no++;
						
						switch($user['VERIFIKATOR_N'])
						{
							case 'pending':
								$stat = "<font color='orange'>Pending</font>";
								break;
							case 'sent':
								$stat = "<font color='green'>Sent</font>";
								break;
							default :
								$stat = "Belum ada tindakan.";
								break;
						}
						
						if($this->session->userdata('role') == 6)
						{
							if($user['STATUS_TK1'] != 'NF'){
								if ($user['LEMBAR_TK1'] != '0'){
									if($user['TK1'] != '0'){
										$tk1 = '<span class="label label-xs bg-info">'.$user['TK1'].'</span> ';
									}else{
										$tk1 = '';
									}
								}else{
									$tk1 = '';
								}
							}else{
								$tk1 = '';
							}
							
							if($user['STATUS_TK2'] != 'NF'){
								if ($user['LEMBAR_TK2'] != '0'){
									if($user['TK2'] != '0'){
										$tk2 = '<span class="label label-xs bg-info">'.$user['TK2'].'</span> ';
									}else{
										$tk2 = '';
									}
								}else{
									$tk2 = '';
								}
							}else{
								$tk2 = '';
							}
							
							if($user['STATUS_TK3'] != 'NF'){
								if ($user['LEMBAR_TK3'] != '0'){
									if($user['TK3'] != '0'){
										$tk3 = '<span class="label label-xs bg-info">'.$user['TK3'].'</span>';
									}else{
										$tk3 = '';
									}
								}else{
									$tk3 = '';
								}
							}else{
								$tk3 = '';
							}

							$tgl = date("d-m-Y",strtotime($user["TGL_PENGAJUAN"]));
							if($user['STATUS_TK1'] != 'NF' || $user['STATUS_TK2'] != 'NF' || $user['STATUS_TK3'] != 'NF')
							{
								echo "<tr>";
								echo "<td>$no</td>";
								echo "<td><a href=".site_url("admin/adlegalisir/lihatPermohonan/$user[ID_PENGAJUAN]")."><button class='btn btn-info btn-xs'><i class='fa fa-eye'></button></a></td>";
								echo "<td>$tgl</td>";
								echo "<td>$user[NAMA_LENGKAP]</td>";
								echo "<td>$tk1$tk2$tk3</td>";
								echo "<td>$stat</td>";
								echo "</tr>";
							}
						}
						
						if($this->session->userdata('role') == 7)
						{
							if($user['STATUS_TK1'] == 'NF'){
								if ($user['LEMBAR_TK1'] != '0'){
									if($user['TK1'] != '0'){
										$tk1 = '<span class="label label-xs bg-info">'.$user['TK1'].'</span> ';
									}else{
										$tk1 = '';
									}
								}else{
									$tk1 = '';
								}
							}else{
								$tk1 = '';
							}
							
							if($user['STATUS_TK2'] == 'NF'){
								if ($user['LEMBAR_TK2'] != '0'){
									if($user['TK2'] != '0'){
										$tk2 = '<span class="label label-xs bg-info">'.$user['TK2'].'</span> ';
									}else{
										$tk2 = '';
									}
								}else{
									$tk2 = '';
								}
							}else{
								$tk2 = '';
							}
							
							if($user['STATUS_TK3'] == 'NF'){
								if ($user['LEMBAR_TK3'] != '0'){
									if($user['TK3'] != '0'){
										$tk3 = '<span class="label label-xs bg-info">'.$user['TK3'].'</span>';
									}else{
										$tk3 = '';
									}
								}else{
									$tk3 = '';
								}
							}else{
								$tk3 = '';
							}

							$tgl = date("d-m-Y",strtotime($user["TGL_PENGAJUAN"]));
							if($user['STATUS_TK1'] == 'NF' || $user['STATUS_TK2'] == 'NF' || $user['STATUS_TK3'] == 'NF')
							{
								echo "<tr>";
								echo "<td>$no</td>";
								echo "<td><a href=".site_url("admin/adlegalisir/lihatPermohonan/$user[ID_PENGAJUAN]")."><button class='btn btn-info btn-xs'><i class='fa fa-eye'></button></a></td>";
								echo "<td>$tgl</td>";
								echo "<td>$user[NAMA_LENGKAP]</td>";
								echo "<td>$tk1$tk2$tk3</td>";
								echo "<td>$stat</td>";
								echo "</tr>";
							}
						}
						
						
					}
				?>
			</tbody>
		</table>
	</div>
	<footer class="panel-footer">
		<div class="row">
			<div class="col-sm-4 text-left">
				<small class="text-muted inline m-t-sm m-b-sm"><?php
					$itemPerPage = 5;
					$page=1;
					if($_SERVER['QUERY_STRING'] != null){
						$page = explode('=', $_SERVER['QUERY_STRING']);
						$page = $page[1];
					}
					$first = ($itemPerPage * ($page-1)) + 1;
					$last = $first + $itemPerPage - 1;
					if($last > $total)
						$last = $total;
					echo "showing $first-$last of $total items";
				?></small>
			</div>
			<div class="col-sm-4 text-right text-center-xs pull-right">                
				
			</div>
		</div>
	</footer>
</section>